<template>
	<view class="content">
		<view v-for="item in tableData" class="content-item">
				<van-cell-group inset @click="Cha(item.Id)">
					<van-cell title="项目名:" :value="item.ProjectName" />
					<van-cell title="开始时间:" :value="item.CreateTime" />
					<van-cell title="截止时间:" :value="dateProp(item.CreateTime,item.Period)" />
				</van-cell-group>
		</view>

	</view>
</template>

<script setup>
	import {
		ref,
		onMounted,
		computed
	} from 'vue'
	import projectapi from '../../api/projectinfoapi'
	const tableData = ref([])
	const dateProp = (date, period) => {
		let dateTime = new Date(date);
		dateTime.setDate(dateTime.getDate() + Number.parseInt(period) * 7);
		return dateTime.toLocaleDateString('zh-CN', {
			timeZone: "Asia/Shanghai"
		});
	}
	projectapi.query({}).then(res => {
		tableData.value = res.data
		console.log("res", tableData.value);
	}).catch(err => {
		console.log("err=>", err);
	})
	const Cha = (data)=>{
		uni.navigateTo({
			url:"../Projectdetails/Projectdetails?id="+data
		});
	}
		
	
</script>

<style scoped>
	.content {
		height: calc(100vh - var(--window-top) - var(--window-bottom));
		background-color: rgb(243, 243, 243);
	}
	.content-item{
		padding: 10px;
	}
</style>